/**
 * Created with IntelliJ IDEA.
 * User: info
 * Email: guobin@ebigdata.org
 * Date: 2017/11/21
 * Time: 9:26
 * To change this template use File | Settings | File Templates.
 */
import http from '@http/http'
const isDev = process.env.NODE_ENV === 'development'
let uriBase = isDev ? '.' : '.'

function servive () {
  let myServices = {}
  /* 获取登录用户 */
  myServices._getLoginUser = () => {
    return http.GET(`${uriBase}/api/user/getLoginUser`)
  }
  /* 注销登录用户 */
  myServices._logout = () => {
    // return http.POST('./api/user/logout')
    return http.GET(`${isDev ? '/root' : ''}/logout`)
  }
  /* 登录用户 */
  myServices._login = (data) => {
    return http.POST('./api/user/login', data)
  }
  /* 登录 */
  myServices.login = (data) => {
    return http.POST('/api/user/login', data)
  }

  /* 获取登录用户菜单 */
  myServices._getRoleMenu = (roleId, appId) => {
    return http.GET(`${uriBase}/api/role/${roleId}/${appId}/menu`)
  }
  myServices._serverMenu = (appId) => http.GET(`${uriBase}/api/role/owner/${appId}/menu`)
  myServices._serverRouter = (appId) => http.GET(`${uriBase}/api/role/owner/${appId}/router/all`)

  // 获取学校Logo
  myServices._getSchoolLogo = () => http.GET(`/system-manage/api/displayConfig/getSchoolNameAndLogo`)

  // 切换岗位
  myServices._switchJob = (jobId) => http.GET(`./api/user/switchJob/${jobId}`)
  return myServices
}

export default servive
